<#--设置报表ID-->
<#assign reportId=report.id?default("AF")>	
<#--设置报表Parameters-->
<#assign parameters=report.parameters?default("")>
<#if parameters==""&&!report.isDeveloperMode()>
	<#assign parameters="Rebar=none;Border=none; Ruler=none; PagesTabPercent=0; SeperateBar=none;">
</#if>
<#--设置默认排序字段-->
<#assign sortname="">	
<#assign sortorder="ASC">	
<#list report.grid.columnList as column >
    <#if column.defaultSort=="true" >
	   <#assign sortname=column.name>
	   <#assign sortorder=column.defaultSortOrder>
	   <#break>
   </#if>
</#list>
<#--设置数据源参数-->
<#assign sourceParameters="?1=1">
<#assign sourceParameters=sourceParameters+"&sourceId="+report.encode(report.sourceId?default("ds1"),"UTF-8")>
<#assign sourceParameters=sourceParameters+"&cache="+report.encode(report.cache?default(""),"UTF-8")>
<#assign sourceParameters=sourceParameters+"&fisherTitle="+report.encode(report.title,"UTF-8")>
<#assign sourceParameters=sourceParameters+"&sortname="+report.encode(sortname,"UTF-8")>
<#assign sourceParameters=sourceParameters+"&sortorder="+report.encode(sortorder,"UTF-8")>
<#assign sourceParameters=sourceParameters+"&query="+report.encode(report.queryValue?default(""),"UTF-8")>
<#assign sourceParameters=sourceParameters+"&qtype="+report.encode(report.queryColumn?default(""),"UTF-8")>
<#assign sourceParameters=sourceParameters+"&dynamic="+report.encode(report.dynamicValue?default(""),"UTF-8")>
<#assign sourceParameters=sourceParameters+"&dtype="+report.encode(report.dynamicColumn?default(""),"UTF-8")>
<#assign sourceParameters=sourceParameters+"&fishergrid="+report.encode(report.name,"UTF-8")>
<#assign sourceParameters=sourceParameters+"&exportIncludeColumns="+report.encode(report.includeColumns?default(""),"UTF-8")>
<#assign sourceParameters=sourceParameters+"&exportExcludeColumns="+report.encode(report.excludeColumns?default(""),"UTF-8")>
<#--设置报表Title-->
<div id='${reportId}Title' class="reportTitle" style="width:${report.width?default("100%")};">
	<span><b>${report.title?html}</b></span>
</div>
<#--设置报表Toolbar-->
<div id='${reportId}Button' class="reportToolbar" style="width:${report.width?default("100%")};height:27px;padding:0;margin:0;border:0;">
	<div class="reportButton" name="导出" onclick="reportTransform('${reportId?js_string}');" onmouseover="$(this).addClass('rbOver');" onmouseout="$(this).removeClass('rbOver');">
	<div><span style="padding-left: 20px" class="reportTransform">导出数据</span></div></div>
	<div class="reportButtonSeparator"></div>
	<div class="reportButton" name="重新计算" onclick="reportCalculate('${reportId?js_string}','${report.sourceId?default("ds1")?js_string}','${(contextPath+report.sourceUrl?default("/fisher/jsp/xml.jsp")+sourceParameters)?js_string}');" onmouseover="$(this).addClass('rbOver');" onmouseout="$(this).removeClass('rbOver');">
	<div><span style="padding-left: 20px" class="reportCalculate">重新计算</span></div></div>
	<div class="reportButtonSeparator"></div>
</div>
<#--设置报表Content-->
<div id='${reportId}Content' style="width:${report.width?default("100%")};height:${report.height?default("96%")};padding:0;margin:0;border:0;">
	<script>
		insertReport("${reportId}", "${parameters}");//AF是Object的id号、第二个参数为空表示没有初始参数
	</script>	
</div>
<script>
	 //OnReady 事件 
	 //id参数说明：如果页面中有多个插件/加载项，那么OnReady事件会被触发多次，id就是插件/加载项的id 
	 function OnReady( id ) 
	 { 
	   //假如执行如下js 
	   if(id=="${reportId}"){
	    	document.getElementById("${reportId}").func("Build", "${contextPath+report.templateUrl?default("/fisher/jsp/sheet.jsp")+sourceParameters}");
			//指定ds1数据源取数的URL地址 
			document.getElementById("${reportId}").func("SetSource", "${report.sourceId?default("ds1")?js_string} \r\n  ${(contextPath+report.sourceUrl?default("/fisher/jsp/xml.jsp")+sourceParameters)?js_string}"); 	    	
	    	document.getElementById("${reportId}").func("calc", "mode=asynch;range=full");
	   } 
	 } 
	 //OnEvent 事件 
	 //OnEvent参数说明: “Event”为事件名，p1,p2,p3,p4参数有特定的含义，由具体的功能组件规定. 
	 function OnEvent(id, Event, p1, p2, p3, p4) 
	 { 
	   //假如执行如下js 
	   if(id=="${reportId}"){
	   	   if(Event=="Toolbar"){
	   	  	 //alert(Event+p1);
	   	  	 if(p1==104){
		   	  	 var content = ${reportId}.func('GetFileXML', '');
		   	  	 //alert(xml);	
		   	  	 var path="${report.templateUrl?default("")}";   	  	 
	   	  	   	 if(path==""){
	   	  	   	 	path= window.prompt("请输入报表模板文件保存相对Webroot路径:","${report.name}");
	   	  	   	 }
	   	  	   	 //alert(path);
	   	  	   	 if(path!=null&&path!=""){//路径存在
						var param={content:content,path:path,encode:"UTF-8"};			
						$.ajax({
						   type: "post",
						   url: "${contextPath}/fisher/jsp/generate.jsp",
						   data: param,
						   dataType: "json",
						   success: function(data){
							   		alert(data.message);
						   		},
						   error: function(data) {alert(data.message);}
						 });	   	  	   	 	
	   	  	   	 }
	   	  	   	 document.getElementById("${reportId}").func("calc", "mode=asynch;range=full");
	   	  	 }
	   	   }
	   } 
	 } 
</script>